using UnityEngine;
using System.Collections;


public class Follower : MonoBehaviour {
	
	private float x, y, z;
	public float rotationX, rotationY, rotationZ;
	
	bool madeTool = false;
	
	
	// Use this for initialization
	void Start () {
		Controller.Start();
	}
	
	// Update is called once per frame
	void Update () {
		
		Controller.Update();
		ConstructionController.Update();
		
		if (Input.GetKey(KeyCode.UpArrow)){
			y += 1;
		} else if (Input.GetKey(KeyCode.DownArrow)){
			y -= 1;
		} else if (Input.GetKey(KeyCode.RightArrow)){
			x += 1;
		} else if (Input.GetKey(KeyCode.LeftArrow)){
			x -= 1;
		} else if (Input.GetKey(KeyCode.A)){
			rotationY += 1;
		} else if (Input.GetKey(KeyCode.D)){
			rotationY -= 1;
		} else if (Input.GetKey(KeyCode.W)){
			rotationX += 1;
		} else if (Input.GetKey(KeyCode.S)){
			rotationX -= 1;
		} else if (Input.GetKey(KeyCode.Z)){
			rotationZ += 1;
		} else if (Input.GetKey(KeyCode.X)){
			rotationZ -= 1;
		} else if (Input.GetKey(KeyCode.Space)){
			if (!madeTool){
				EquipJob j = new EquipJob(new MiningTool(new GalvanizedSteel(), 5, 0, 15), 5, 0, 15);
				Controller.addJob(j);
				madeTool = true;
			}
		} 
		
		z += ((Input.GetAxis("Mouse ScrollWheel")));
		
		transform.position = getVector();
		transform.Rotate(rotationX, rotationY, rotationZ);
		rotationX = 0;
		rotationY = 0;
		rotationZ = 0;
	}
	
	public Vector3 getVector(){
		Vector3 vector = new Vector3(x, y, z);
		return vector;
	}
	
	
}
